package entity.Car.dao.impl;

import entity.Car.dao.CarDao;
import entity.Car.model.Car;
import entity.Car.model.Transport;
import entity.Car.model.reference.*;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.util.List;

/**
 * Created by vanches on 7.1.15.
 */
public class CarDaoImpl extends HibernateDaoSupport implements CarDao {
    @Override
    public List<Car> getAllCar() {
        return  getHibernateTemplate().find("from Car ");
    }

    @Override
    public List<Car> carSearch(Brand brand, Model model, double priceMin, double priceMax) {
        List list = getHibernateTemplate().find("from Car where transport.brand.nameEn='"+brand.getNameEn()+"'"+" and model.nameEn='"+model.getNameEn()+"'");
             
        return list;
    }

    @Override
    public Car getCarId(int id) {
        return (Car) getHibernateTemplate().find("from Car where id="+id).get(0);
    }

    @Override
    public void addCar(Car car, Transport transport) {
        getHibernateTemplate().save(transport);
        getHibernateTemplate().save(car);
    }

    @Override
    public void deleteCar(Car car) {

    }

    @Override
    public void updateCar(Car car) {

    }

    @Override
    public List<Transmission> getAllTransmission() {
        return  getHibernateTemplate().find("from Transmission ");
    }

    @Override
    public Transmission getTransmissionId(int id) {
        return (Transmission) getHibernateTemplate().find("from Transmission where id="+id).get(0);
    }

    @Override
    public void addTransmission(Transmission transmission) {

    }

    @Override
    public void deleteTransmission(Transmission transmission) {

    }

    @Override
    public void updateTransmission(Transmission transmission) {

    }

    @Override
    public List<BodyType> getAllBodyType() {
        return  getHibernateTemplate().find("from BodyType ");
    }

    @Override
    public BodyType getBodyTypeId(int id) {
        return (BodyType) getHibernateTemplate().find("from BodyType where id="+id).get(0);
    }

    @Override
    public void addBodyType(BodyType bodyType) {

    }

    @Override
    public void deleteBodyType(BodyType bodyType) {

    }

    @Override
    public void updateBodyType(BodyType bodyType) {

    }

    @Override
    public List<Brand> getAllBrand() {
        return  getHibernateTemplate().find("from Brand ");
    }

    @Override
    public Brand getBrandId(int id) {
        return (Brand) getHibernateTemplate().find("from Brand where id="+id).get(0);
    }

    @Override
    public void addBrand(Brand brand) {

    }

    @Override
    public void deleteBrand(Brand brand) {

    }

    @Override
    public void updateBrand(Brand brand) {

    }

    @Override
    public List<Color> getAllColor() {
        return  getHibernateTemplate().find("from Color ");
    }

    @Override
    public Color getColorId(int id) {
        return (Color) getHibernateTemplate().find("from Color where id="+id).get(0);
    }

    @Override
    public void addColor(Color color) {

    }

    @Override
    public void deleteColor(Color color) {

    }

    @Override
    public void updateColor(Color color) {

    }

    @Override
    public List<Condition> getAllCondition() {
        return  getHibernateTemplate().find("from Condition ");
    }

    @Override
    public Condition getConditionId(int id) {
        return (Condition) getHibernateTemplate().find("from Condition where id="+id).get(0);
    }

    @Override
    public void addCondition(Condition condition) {

    }

    @Override
    public void deleteCondition(Condition condition) {

    }

    @Override
    public void updateCondition(Condition condition) {

    }

    @Override
    public List<Currency> getAllCurrency() {
        return  getHibernateTemplate().find("from Currency ");
    }

    @Override
    public Currency getCurrencyId(int id) {
        return (Currency) getHibernateTemplate().find("from Currency where id="+id).get(0);
    }

    @Override
    public void addCurrency(Currency currency) {

    }

    @Override
    public void deleteCurrency(Currency currency) {

    }

    @Override
    public void updateCurrency(Currency currency) {

    }

    @Override
    public List<Model> getAllModel() {
        return  getHibernateTemplate().find("from Model ");
    }

    @Override
    public Model getModelId(int id) {
        return (Model) getHibernateTemplate().find("from Model where id="+id).get(0);
    }

    @Override
    public void addModel(Model model) {

    }

    @Override
    public void deleteModel(Model model) {

    }

    @Override
    public void updateModel(Model model) {

    }

    @Override
    public List<Privod> getAllPrivod() {
        return  getHibernateTemplate().find("from Privod ");
    }

    @Override
    public Privod getPrivodId(int id) {
        return (Privod) getHibernateTemplate().find("from Privod where id="+id).get(0);
    }

    @Override
    public void addPrivod(Privod privod) {

    }

    @Override
    public void deletePrivod(Privod privod) {

    }

    @Override
    public void updatePrivod(Privod privod) {

    }

    @Override
    public List<TypeEngine> getAllTypeEngine() {
        return  getHibernateTemplate().find("from TypeEngine ");
    }

    @Override
    public TypeEngine getTypeEngineId(int id) {
        return (TypeEngine) getHibernateTemplate().find("from TypeEngine where id="+id).get(0);
    }

    @Override
    public void addTypeEngine(TypeEngine typeEngine) {

    }

    @Override
    public void deleteTypeEngine(TypeEngine typeEngine) {

    }

    @Override
    public void updateTypeEngine(TypeEngine typeEngine) {

    }
}
